package com.ripplezjw.blog.controller;

import com.ripplezjw.blog.Service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

@Controller
public class ArticleController {
    @Autowired
    ArticleService articleService;

    @GetMapping("/article/{articleId}")
    public String article(@PathVariable("articleId") int articleId,
                          Model model) {
        model.addAttribute("article", articleService.getArticleById(articleId));
        return "article";
    }
}
